//class MyThread extends Thread{            //------------------------------自己记下来任务
//    public void run() {
//        while (true) {
//            System.out.println("hello thread ---");
//            try {
//                Thread.sleep(1000); //单位ms，1000ms即1秒，休眠1秒
//            }catch (InterruptedException e){
//                e.printStackTrace();
//            }
//        }
//    }
//}
//public class Main {
//    public static void main(String[] args) {
//        Thread t = new MyThread();
////        t.start();
//        t.run();
//        while (true){
//            System.out.println("hello main +++");
//            try {
//                Thread.sleep(1000);
//            }catch (InterruptedException e){
//                e.printStackTrace();
//            }
//        }
//    }
//}


//-------------------------------------解耦合，以后修改更简单（由别人记下来任务）
class MyRunnable implements Runnable{

    public void run() {
        while (true) {
            System.out.println("hello thread ---");
            try {
                Thread.sleep(1000); //单位ms，1000ms即1秒，休眠1秒
            }catch (InterruptedException e){
                e.printStackTrace();
            }
        }
    }
}
public class Main {
    public static void main(String[] args) {
        Thread t = new Thread(new MyRunnable());
        t.start();
        while (true){
            System.out.println("hello main +++");
            try {
                Thread.sleep(1000);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
        }
    }
}